package com;

import org.apache.log4j.Logger;

import com.game.ClientGame;
import com.game.ClientGameAPI;

/**
 * User: wattsc5
 * <p/>
 * Date: 2/28/12
 */
public class ClientMain
{
	private static final Logger logger = Logger.getLogger(ClientMain.class);

	public static void main(String[] args)
	{
		int port = 8888;
		String hostAddress = "localhost";
		boolean useAI = false;

		// Check for args
		for (int i = 0; i < args.length; i++)
		{
			// Handle port change
			if (args[i].equals("-h"))
			{
				hostAddress = args[i + 1];
				i++;
			}
			else if (args[i].equals("-p"))
			{
				// Handle port change
				port = Integer.parseInt(args[i + 1]);
				i++;
			}
			else if(args[i].equals("-a"))
			{
				useAI = true;
			}
		}

		logger.info("Host set to " + hostAddress);
		logger.info("Port set to " + port);
		ClientGame game = new ClientGame();
		ClientGameAPI api = new ClientGameAPI(game);
		game.initializeGame(api, hostAddress, port, useAI);
		game.start();
	}
}
